TASK_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))

include ../../config.mk

# Inputs
RMD_FILE := $(TASK_DIR)/src/gen_outreach_model_outputs.Rmd
CONFIG_FILE := $(TASK_DIR)/hand/config.yaml
OUTREACH_RESULTS := $(TASK_DIR)/../../run_regressions/output/regression_output__outreach.csv
HOURS_WORKED_RESULTS := $(TASK_DIR)/../../run_regressions/output/regression_output__hours_worked.csv

# One of the outputs
OUT_FILE := $(OUT_DIR)/outreach_model_up_to_date.tex

$(OUT_FILE): $(RMD_FILE) $(CONFIG_FILE) $(OUTREACH_RESULTS) $(HOURS_WORKED_RESULTS) $(OUTCOME_LABELS_FILE) $(TABLE_CONFIG)
	@mkdir -p $(OUT_DIR)
	@mkdir -p $(PAPER_OUT_DIR)
	$(R_script) -e "rmarkdown::render(input = '$(RMD_FILE)')"
	@cp $(OUT_DIR)/*up_to_date.tex $(PAPER_OUT_DIR)

.PHONY: all clean
.DEFAULT_GOAL=all

all: $(OUT_FILE)

clean:
	rm -rf $(OUT_DIR)/*up_to_date*
